package com.project.action;

import java.util.Date;
import java.util.List;

import net.sf.json.JSONArray;

import com.project.entity.*;
import com.project.service.*;

public class DataManageAction {
	private String beginYear;// 查询开始时间
	private String endYear;// 查询结束时间
	private String keyWordType;// 关键字段
	private String keyWord;// 关键字
	private String rad;// 排序方式选择

	private Integer start;//前台传回的页码
	private Integer limit;//固定每页显示记录数量为20.

	// projectManagement对象所需参数。ID自动添加
	private String projectnumber;
	private String projectname;
	private String location;
	private Integer mainundertakeunit;
	private Integer guaranteeunit;
	private String unitedunitone;
	private String unitedunittwo;
	private String unitedunitthree;
	private String unitedunitfour;
	private String establishprojectyear;
	private String mainmanagingdepartment;
	private Integer followupperson;
	private String projectplancatagory;
	private String field;
	private String subfield;
	private String issuefilenumber;
	private Date contractbegin;
	private Date contractend;
	private Float winbidmoney;
	private Integer projectdirector;
	private String officephone;
	private String mobilephone;
	private String directoremail;
	private Integer contactman;
	private String phoneone;
	private String phonetwo;
	private String contactmanemail;
	private Date checkdate;
	private String projectschedule;
	private String projectchange;
	private Integer inventpatentapplication;
	private Integer inventpatentauthorization;
	private Integer usenewapplication;
	private Integer usenewauthorization;
	private Integer appearancedesignapplication;
	private Integer appearancedesignauthorization;
	private Integer foreignpatent;
	private Integer newtechnology;
	private Integer newproduct;
	private Integer newmaterial;
	private Integer newequipment;
	private Integer computersoftware;
	private Integer paper;
	private Integer technologystandard;
	private Integer nationalaward;
	private Integer provincialaward;
	private Integer cityaward;
	private Integer doctor;
	private Integer master;
	private Integer undergraduate;
	private Float fundsavailable;
	private Float fundsinvestment;
	private Float benefitacquired;
	private String projectsummary;
	private String sparefield1;
	private String sparefield2;
	private String sparefield3;

	private String jsonString;// 使用json传递数据
	private DataManage datamanageService; // service

	/*
	 * 获取所有的project
	 */
	public String getAllProject() {
		
		if(start ==null||start<=0){
			this.start = 1;
		}
//		System.out.println(pageNum);
		List<ProjectManagement> projectList = this.datamanageService
				.getAllProject(start-1,start+limit-1);
		JSONArray jsonObject = JSONArray.fromObject(projectList);
		this.setJsonString("{success:true,totalCount : " + this.datamanageService.countAllProject()
				+ ", list:" + jsonObject.toString() + "}");
		return "success";
	}

	/*
	 * 插入新project信息
	 */
	public String addProject() {
		ProjectManagement tmp = new ProjectManagement();
		tmp.setAppearancedesignapplication(appearancedesignapplication);
		tmp.setAppearancedesignauthorization(appearancedesignauthorization);
		tmp.setBenefitacquired(benefitacquired);
		tmp.setCheckdate(checkdate);
		tmp.setCityaward(cityaward);
		tmp.setComputersoftware(computersoftware);
		tmp.setContactman(contactman);
		tmp.setContactmanemail(contactmanemail);
		tmp.setContractbegin(contractbegin);
		tmp.setContractend(contractend);
		tmp.setDirectoremail(directoremail);
		tmp.setDoctor(doctor);
		tmp.setEstablishprojectyear(establishprojectyear);
		tmp.setField(field);
		tmp.setFollowupperson(followupperson);
		tmp.setForeignpatent(foreignpatent);
		tmp.setFundsavailable(fundsavailable);
		tmp.setFundsinvestment(fundsinvestment);
		tmp.setGuaranteeunit(guaranteeunit);
		tmp.setInventpatentapplication(inventpatentapplication);
		tmp.setInventpatentauthorization(inventpatentauthorization);
		tmp.setIssuefilenumber(issuefilenumber);
		tmp.setLocation(location);
		tmp.setMainmanagingdepartment(mainmanagingdepartment);
		tmp.setMainundertakeunit(mainundertakeunit);
		tmp.setMaster(master);
		tmp.setMobilephone(mobilephone);
		tmp.setNationalaward(nationalaward);
		tmp.setNewequipment(newequipment);
		tmp.setNewmaterial(newmaterial);
		tmp.setNewproduct(newproduct);
		tmp.setNewtechnology(newtechnology);
		tmp.setOfficephone(officephone);
		tmp.setPaper(paper);
		tmp.setPhoneone(phoneone);
		tmp.setPhonetwo(phonetwo);
		tmp.setProjectchange(projectchange);
		tmp.setProjectdirector(projectdirector);
		// tmp.setProjectid(projectid);
		tmp.setProjectname(projectname);
		tmp.setProjectnumber(projectnumber);
		tmp.setProjectplancatagory(projectplancatagory);
		tmp.setProjectschedule(projectschedule);
		tmp.setProjectsummary(projectsummary);
		tmp.setProvincialaward(provincialaward);
		tmp.setSubfield(subfield);
		tmp.setTechnologystandard(technologystandard);
		tmp.setUndergraduate(undergraduate);
		tmp.setUnitedunitfour(unitedunitfour);
		tmp.setUnitedunitone(unitedunitone);
		tmp.setUnitedunitthree(unitedunitthree);
		tmp.setUnitedunittwo(unitedunittwo);
		tmp.setUsenewapplication(usenewapplication);
		tmp.setUsenewauthorization(usenewauthorization);
		tmp.setWinbidmoney(winbidmoney);

		JSONArray jsonObject = JSONArray.fromObject(tmp);
		this.setJsonString("{success:true,totalCount : " + "1" + ", list:"
				+ jsonObject.toString() + "}");
		return "success";
	}

	/*
	 * 条件查询
	 */
	public String conditionQuery() {
		// 传查询条件到service
		List<ProjectManagement> projectList = this.datamanageService
				.multiConditionQuery(this.keyWordType, this.keyWord,
						this.beginYear, this.endYear);
		// 将查询结果写入JSON
		JSONArray jsonObject = JSONArray.fromObject(projectList);
		this.setJsonString("{success:true,totalCount : " + projectList.size()
				+ ", list:" + jsonObject.toString() + "}");
		// 返回
		return "success";
	}

	/**
	 * getter and
	 * setter~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
	 **/

	public String getJsonString() {
		return jsonString;
	}

	public String getBeginYear() {
		return beginYear;
	}

	public void setBeginYear(String beginYear) {
		this.beginYear = beginYear;
	}

	public String getEndYear() {
		return endYear;
	}

	public void setEndYear(String endYear) {
		this.endYear = endYear;
	}

	public String getKeyWordType() {
		return keyWordType;
	}

	public void setKeyWordType(String keyWordType) {
		this.keyWordType = keyWordType;
	}

	public String getKeyWord() {
		return keyWord;
	}

	public void setKeyWord(String keyWord) {
		this.keyWord = keyWord;
	}

	public String getRad() {
		return rad;
	}

	public void setRad(String rad) {
		this.rad = rad;
	}

	public void setJsonString(String jsonString) {
		this.jsonString = jsonString;
	}

	public DataManage getDatamanageService() {
		return datamanageService;
	}

	public void setDatamanageService(DataManage datamanageService) {
		this.datamanageService = datamanageService;
	}

	public String getProjectnumber() {
		return projectnumber;
	}

	public void setProjectnumber(String projectnumber) {
		this.projectnumber = projectnumber;
	}

	public String getProjectname() {
		return projectname;
	}

	public void setProjectname(String projectname) {
		this.projectname = projectname;
	}

	public String getLocation() {
		return location;
	}

	public void setLocation(String location) {
		this.location = location;
	}

	public Integer getMainundertakeunit() {
		return mainundertakeunit;
	}

	public void setMainundertakeunit(Integer mainundertakeunit) {
		this.mainundertakeunit = mainundertakeunit;
	}

	public Integer getGuaranteeunit() {
		return guaranteeunit;
	}

	public void setGuaranteeunit(Integer guaranteeunit) {
		this.guaranteeunit = guaranteeunit;
	}

	public String getUnitedunitone() {
		return unitedunitone;
	}

	public void setUnitedunitone(String unitedunitone) {
		this.unitedunitone = unitedunitone;
	}

	public String getUnitedunittwo() {
		return unitedunittwo;
	}

	public void setUnitedunittwo(String unitedunittwo) {
		this.unitedunittwo = unitedunittwo;
	}

	public String getUnitedunitthree() {
		return unitedunitthree;
	}

	public void setUnitedunitthree(String unitedunitthree) {
		this.unitedunitthree = unitedunitthree;
	}

	public String getUnitedunitfour() {
		return unitedunitfour;
	}

	public void setUnitedunitfour(String unitedunitfour) {
		this.unitedunitfour = unitedunitfour;
	}

	public String getEstablishprojectyear() {
		return establishprojectyear;
	}

	public void setEstablishprojectyear(String establishprojectyear) {
		this.establishprojectyear = establishprojectyear;
	}

	public String getMainmanagingdepartment() {
		return mainmanagingdepartment;
	}

	public void setMainmanagingdepartment(String mainmanagingdepartment) {
		this.mainmanagingdepartment = mainmanagingdepartment;
	}

	public Integer getFollowupperson() {
		return followupperson;
	}

	public void setFollowupperson(Integer followupperson) {
		this.followupperson = followupperson;
	}

	public String getProjectplancatagory() {
		return projectplancatagory;
	}

	public void setProjectplancatagory(String projectplancatagory) {
		this.projectplancatagory = projectplancatagory;
	}

	public String getField() {
		return field;
	}

	public void setField(String field) {
		this.field = field;
	}

	public String getSubfield() {
		return subfield;
	}

	public void setSubfield(String subfield) {
		this.subfield = subfield;
	}

	public String getIssuefilenumber() {
		return issuefilenumber;
	}

	public void setIssuefilenumber(String issuefilenumber) {
		this.issuefilenumber = issuefilenumber;
	}

	public Date getContractbegin() {
		return contractbegin;
	}

	public void setContractbegin(Date contractbegin) {
		this.contractbegin = contractbegin;
	}

	public Date getContractend() {
		return contractend;
	}

	public void setContractend(Date contractend) {
		this.contractend = contractend;
	}

	public Float getWinbidmoney() {
		return winbidmoney;
	}

	public void setWinbidmoney(Float winbidmoney) {
		this.winbidmoney = winbidmoney;
	}

	public Integer getProjectdirector() {
		return projectdirector;
	}

	public void setProjectdirector(Integer projectdirector) {
		this.projectdirector = projectdirector;
	}

	public String getOfficephone() {
		return officephone;
	}

	public void setOfficephone(String officephone) {
		this.officephone = officephone;
	}

	public String getMobilephone() {
		return mobilephone;
	}

	public void setMobilephone(String mobilephone) {
		this.mobilephone = mobilephone;
	}

	public String getDirectoremail() {
		return directoremail;
	}

	public void setDirectoremail(String directoremail) {
		this.directoremail = directoremail;
	}

	public Integer getContactman() {
		return contactman;
	}

	public void setContactman(Integer contactman) {
		this.contactman = contactman;
	}

	public String getPhoneone() {
		return phoneone;
	}

	public void setPhoneone(String phoneone) {
		this.phoneone = phoneone;
	}

	public String getPhonetwo() {
		return phonetwo;
	}

	public void setPhonetwo(String phonetwo) {
		this.phonetwo = phonetwo;
	}

	public String getContactmanemail() {
		return contactmanemail;
	}

	public void setContactmanemail(String contactmanemail) {
		this.contactmanemail = contactmanemail;
	}

	public Date getCheckdate() {
		return checkdate;
	}

	public void setCheckdate(Date checkdate) {
		this.checkdate = checkdate;
	}

	public String getProjectschedule() {
		return projectschedule;
	}

	public void setProjectschedule(String projectschedule) {
		this.projectschedule = projectschedule;
	}

	public String getProjectchange() {
		return projectchange;
	}

	public void setProjectchange(String projectchange) {
		this.projectchange = projectchange;
	}

	public Integer getInventpatentapplication() {
		return inventpatentapplication;
	}

	public void setInventpatentapplication(Integer inventpatentapplication) {
		this.inventpatentapplication = inventpatentapplication;
	}

	public Integer getInventpatentauthorization() {
		return inventpatentauthorization;
	}

	public void setInventpatentauthorization(Integer inventpatentauthorization) {
		this.inventpatentauthorization = inventpatentauthorization;
	}

	public Integer getUsenewapplication() {
		return usenewapplication;
	}

	public void setUsenewapplication(Integer usenewapplication) {
		this.usenewapplication = usenewapplication;
	}

	public Integer getUsenewauthorization() {
		return usenewauthorization;
	}

	public void setUsenewauthorization(Integer usenewauthorization) {
		this.usenewauthorization = usenewauthorization;
	}

	public Integer getAppearancedesignapplication() {
		return appearancedesignapplication;
	}

	public void setAppearancedesignapplication(
			Integer appearancedesignapplication) {
		this.appearancedesignapplication = appearancedesignapplication;
	}

	public Integer getAppearancedesignauthorization() {
		return appearancedesignauthorization;
	}

	public void setAppearancedesignauthorization(
			Integer appearancedesignauthorization) {
		this.appearancedesignauthorization = appearancedesignauthorization;
	}

	public Integer getForeignpatent() {
		return foreignpatent;
	}

	public void setForeignpatent(Integer foreignpatent) {
		this.foreignpatent = foreignpatent;
	}

	public Integer getNewtechnology() {
		return newtechnology;
	}

	public void setNewtechnology(Integer newtechnology) {
		this.newtechnology = newtechnology;
	}

	public Integer getNewproduct() {
		return newproduct;
	}

	public void setNewproduct(Integer newproduct) {
		this.newproduct = newproduct;
	}

	public Integer getNewmaterial() {
		return newmaterial;
	}

	public void setNewmaterial(Integer newmaterial) {
		this.newmaterial = newmaterial;
	}

	public Integer getNewequipment() {
		return newequipment;
	}

	public void setNewequipment(Integer newequipment) {
		this.newequipment = newequipment;
	}

	public Integer getComputersoftware() {
		return computersoftware;
	}

	public void setComputersoftware(Integer computersoftware) {
		this.computersoftware = computersoftware;
	}

	public Integer getPaper() {
		return paper;
	}

	public void setPaper(Integer paper) {
		this.paper = paper;
	}

	public Integer getTechnologystandard() {
		return technologystandard;
	}

	public void setTechnologystandard(Integer technologystandard) {
		this.technologystandard = technologystandard;
	}

	public Integer getNationalaward() {
		return nationalaward;
	}

	public void setNationalaward(Integer nationalaward) {
		this.nationalaward = nationalaward;
	}

	public Integer getProvincialaward() {
		return provincialaward;
	}

	public void setProvincialaward(Integer provincialaward) {
		this.provincialaward = provincialaward;
	}

	public Integer getCityaward() {
		return cityaward;
	}

	public void setCityaward(Integer cityaward) {
		this.cityaward = cityaward;
	}

	public Integer getDoctor() {
		return doctor;
	}

	public void setDoctor(Integer doctor) {
		this.doctor = doctor;
	}

	public Integer getMaster() {
		return master;
	}

	public void setMaster(Integer master) {
		this.master = master;
	}

	public Integer getUndergraduate() {
		return undergraduate;
	}

	public void setUndergraduate(Integer undergraduate) {
		this.undergraduate = undergraduate;
	}

	public Float getFundsavailable() {
		return fundsavailable;
	}

	public void setFundsavailable(Float fundsavailable) {
		this.fundsavailable = fundsavailable;
	}

	public Float getFundsinvestment() {
		return fundsinvestment;
	}

	public void setFundsinvestment(Float fundsinvestment) {
		this.fundsinvestment = fundsinvestment;
	}

	public Float getBenefitacquired() {
		return benefitacquired;
	}

	public void setBenefitacquired(Float benefitacquired) {
		this.benefitacquired = benefitacquired;
	}

	public String getProjectsummary() {
		return projectsummary;
	}

	public void setProjectsummary(String projectsummary) {
		this.projectsummary = projectsummary;
	}

	public String getSparefield1() {
		return sparefield1;
	}

	public void setSparefield1(String sparefield1) {
		this.sparefield1 = sparefield1;
	}

	public String getSparefield2() {
		return sparefield2;
	}

	public void setSparefield2(String sparefield2) {
		this.sparefield2 = sparefield2;
	}

	public String getSparefield3() {
		return sparefield3;
	}

	public void setSparefield3(String sparefield3) {
		this.sparefield3 = sparefield3;
	}

	public Integer getStart() {
		return start;
	}

	public void setStart(Integer start) {
		this.start = start;
	}

	public Integer getLimit() {
		return limit;
	}

	public void setLimit(Integer limit) {
		this.limit = limit;
	}



	
}
